package com.itheima.user.controller;

import com.itheima.user.pojo.User;
import com.itheima.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@RefreshScope//刷新配置
public class UserController {
    @Autowired
    public UserService userService;

    @Value("${test.name}")
    private String name;

    /**
     * restful风格：请求路径加+请求参数--》http://localhost:8080/user/{参数}
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public User queryById(@PathVariable Long id){
        System.out.println("*****配置中心的test.name = "+name);
        return userService.queryById(id);
    }
}
